home *** CD-ROM | disk | FTP | other *** search
- #include "about.h"
- #include "prefs.h"
- #include "util.h"
- #include "window layer.h"
- #include "graphics.h"
-
- /*-----------------------------------------------------------------------------------*/
- /* internal stuff for about.c */
-
- static void GetTheNextLine(Handle textHandle, unsigned long theSize, unsigned long *pos, Str255 theLine);
- static void DrawTheAboutString(Str255 theString, short *theRow, short theCenter);
-
- static Boolean gUseAlternate;
-
- void SetupTheAboutWindow(WindowPtr theWindow)
- {
- unsigned char *titleStr="\pAbout";
-
- SetWindowWidth(theWindow, 170);
- SetWindowHeight(theWindow, 216);
- SetWindowType(theWindow, noGrowDocProc);
- SetWindowTitle(theWindow, titleStr);
- SetWindowHasCloseBox(theWindow, TRUE);
- SetWindowMaxDepth(theWindow, 1);
- SetWindowDepth(theWindow, 1);
- SetWindowIsFloat(theWindow, FALSE);
- SetWindowAutoCenter(theWindow, TRUE);
- }
-
- void OpenTheAboutWindow(WindowPtr theWindow)
- {
- KeyMap rawKeys;
- unsigned short theKeys[8];
-
- GetKeys(rawKeys);
- Mymemcpy((Ptr)theKeys, (Ptr)rawKeys, sizeof(rawKeys));
- if (theKeys[3]&4) /* option key down? */
- {
- if (!gUseAlternate)
- gUseAlternate=TRUE;
- }
- else
- {
- if (gUseAlternate)
- gUseAlternate=FALSE;
- }
- }
-
- void DrawTheAboutWindow(WindowPtr theWindow, short theDepth)
- {
- short row;
- Handle textHandle;
- Str255 theLine;
- unsigned long pos;
- unsigned long theSize;
- GrafPtr curPort;
- short theCenter;
- RGBColor myGray={49152, 49152, 49152};
- Boolean isColor;
-
- isColor=(theDepth>2);
- GetPort(&curPort);
- FillRect(&(curPort->portRect), &qd.black);
- TextMode(srcXor);
-
- theCenter=(curPort->portRect.right-curPort->portRect.left)/2;
-
- TextFont(geneva);
- TextSize(9);
- row=16;
- textHandle=GetResource('TEXT', gUseAlternate ? 129 : 128);
- if (textHandle==0L)
- return;
- if (*textHandle==0L)
- LoadResource(textHandle);
- if (*textHandle==0L)
- return;
- pos=0L;
- theSize=SizeResource(textHandle);
- do
- {
- GetTheNextLine(textHandle, theSize, &pos, theLine);
- DrawTheAboutString(theLine, &row, theCenter);
- }
- while (pos<theSize);
- ReleaseResource(textHandle);
- DrawTheAboutString(gMyName, &row, theCenter);
- DrawTheAboutString(gMyOrg, &row, theCenter);
- }
-
- void KeyDownInAboutWindow(WindowPtr theWindow, unsigned char theChar)
- {
- CloseTheWindow(theWindow);
- }
-
- void MouseDownInAboutWindow(WindowPtr theWindow, Point thePoint)
- {
- CloseTheWindow(theWindow);
- }
-
- static void GetTheNextLine(Handle textHandle, unsigned long theSize, unsigned long *pos, Str255 theLine)
- {
- unsigned char theChar;
-
- theLine[0]=0x00;
- while ((*pos<theSize) && ((theChar=*((unsigned char*)(((long)(*textHandle))+((*pos)++))))!=0x0d))
- theLine[++theLine[0]]=theChar;
- }
-
- static void DrawTheAboutString(Str255 theString, short *theRow, short theCenter)
- {
- MoveTo(theCenter-StringWidth(theString)/2, *theRow);
- DrawString(theString);
- *theRow+=12;
- }
-